<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <input type="text" id="num1" placeholder="请输入一个数" />
    <input type="text" id="num2" placeholder="请输入一个数" />
    <button id="btn">计算</button>
    <script>
      function calc(a, b) {
        document.write(a + b);
      }
      btn.onclick = function () {
        var num_1 = document.getElementById("num1");
        var num_2 = document.getElementById("num2");
        var a = parseInt(num_1.value);
        var b = parseInt(num_2.value);
        calc(a, b);
      };
    </script>
  </body>
</html>
